use getset::{Getters, Setters};

#[derive(serde::Serialize, serde::Deserialize, Debug, Getters, Setters)]
#[getset(get = "pub with_prefix", set = "pub")]
pub struct PayLoad<T> {
    code: i32,
    message: String,
    data: T,
}

//默认函数
impl<T> Default for PayLoad<T>
where
    T: Default,
{
    fn default() -> Self {
        PayLoad {
            code: i32::default(),
            message: String::default(),
            data: T::default(),
        }
    }
}

impl<T> PayLoad<T>
where
    T: for<'a> serde::Deserialize<'a> + serde::Serialize,
{
    pub fn new(code: i32, message: String, data: T) -> Self {
        PayLoad {
            code,
            message,
            data,
        }
    }
}
